import unittest
# 导入参数化插件
from parameterized import parameterized
# 通过函数提供参数
def get_data():
    return [
        (1, 2, 3),
        (3, 4, 7),
        (5, 6, 11),
        (7, 8, 15),
    ]
def add(a, b):
    return a + b
class TestParam(unittest.TestCase):
    # 测试用例中使用的值改为参数化
    # @parameterized.expand([(1, 2, 3),(3, 4, 7),(5, 6, 11)])
    @parameterized.expand(get_data)
    def test_add01(self, n1, n2, expect):
        result = add(n1, n2)
        self.assertEqual(result, expect)

if __name__ == '__main__':
    # 运行测试用例
    unittest.main()
